Imports System.Data.SqlClient

Public Class FmisF

    Public Function Xuat_Import(ByVal SoQt As String, ByVal Soct As String) As Boolean
        Dim myProjCnn As New ProjectConnection
        Dim myCnn As New SqlConnection
        Dim myDat As New SqlDataAdapter
        Dim myDtb As New DataTable

        myCnn = myProjCnn.GetConnection
        myCnn.Open()

        Dim myCmd As New SqlCommand
        With myCmd
            .Connection = myCnn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "_FmisXuat_Import"

            .Parameters.Add(New SqlClient.SqlParameter("@soqt", SqlDbType.Char))
            .Parameters("@soqt").Value = SoQt

            .Parameters.Add(New SqlClient.SqlParameter("@soct", SqlDbType.Char))
            .Parameters("@soct").Value = Soct

            .Parameters.Add(New SqlClient.SqlParameter("@return", SqlDbType.Bit)).Direction = ParameterDirection.ReturnValue
            .ExecuteNonQuery()
        End With

        If myCmd.Parameters("@return").Value = 1 Then
            myCnn.Close()
            myCnn.Dispose()
            Return True
        Else
            myCnn.Close()
            myCnn.Dispose()
            Return False
        End If

    End Function

    Public Function Xuat_Exists_SoCt(ByVal Soct As String) As Boolean
        Dim myProjCnn As New ProjectConnection
        Dim myCnn As New SqlConnection
        Dim myDat As New SqlDataAdapter
        Dim myDtb As New DataTable

        myCnn = myProjCnn.GetConnection
        myCnn.Open()

        Dim myCmd As New SqlCommand
        With myCmd
            .Connection = myCnn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "_FmisXuat_Exists_SoCt"

            .Parameters.Add(New SqlClient.SqlParameter("@soct", SqlDbType.Char))
            .Parameters("@soct").Value = Soct

        End With

        myDat = New SqlDataAdapter(myCmd)
        myDat.Fill(myDtb)
        If myDtb.Rows.Count = 1 Then
            myCnn.Close()
            myCnn.Dispose()
            Return True
        Else
            myCnn.Close()
            myCnn.Dispose()
            Return False
        End If
    End Function

End Class
